<?php
//获取传入的参数信息
$n=$_GET['nickname'];
$p=$_GET['password'];
$s=$_GET['phone'];

//连接数据库
$link=mysqli_connect("localhost",'root','','shop');
//设置编码
mysqli_set_charset($link,"utf8");
//SQL语句
$ins="insert into user(name,password,phone) values('$n','$p',$s)";

$sel="SELECT * FROM user where name='$n'";

$creat = "create table $n(id int primary key auto_increment ,user varchar(2000),img varchar(255),name varchar(255),price varchar(255),number varchar(2000),size varchar(255),xzk varchar(255))";

//执行SQL语句
$result1=mysqli_query($link,$sel);
//判断用户名是否存在
if(($row=mysqli_fetch_assoc($result1))!=null){
    echo '<script>
        alert("十分抱歉！！！该用户名已存在");
        location="../html/zhuce.html";
    </script>';
}else{
    //执行SQL语句
    $result2=mysqli_query($link,$ins);
    //判断SQL语句是否执行成功
    if($result2){
        echo '<script>
            sessionStorage.state="注册成功";
            location="../html/status.html";
        </script>';
        $result3=mysqli_query($link,$creat);
    }else{
        echo '<script>
            alert("注册失败");
            location="../html/zhuce.html";
        </script>';
    }
}
//关闭数据库连接
mysqli_close($link);

?>